<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>会议室管理</title>
<script type="text/javascript">
	var grid;
	var grid1;
	$(function() {
		grid = $("#grid").datagrid($.extend(datagridOption, {
			title : "会议室管理",
			fitColumns : true,
			url : "${ctx}/basic/meetingRoom/dataGrid",
			columns : [ [ {
				field : 'id',
				checkbox : true
			}, {
				field : 'mrName',
				title : '会议室名称',
				width : 40,
				sortable : true
			}, {
				field : 'mrAddress',
				title : '会议室地址',
				width : 80,
				sortable : true
			}, {
				field : 'mrSize',
				title : '会议时容量',
				width : 40,
				sortable : true
			}, {
				field : 'remark',
				title : '备注',
				width : 80,
				sortable : true
			}, {
				field : 'enable',
				title : '是否启用',
				width : 40,
				formatter : function(value, row, index) {
					return value == 1 ? "是" : "否";
				}
			} ] ]
		}));
		$("#grid").datagrid('enableFilter', [ {
			field : 'mrSize',
			javaType : 'N'
		}, {
			field : 'enable',
			type : 'combobox',
			javaType : 'I',
			options : {
				panelHeight : 'auto',
				data : [ {
					value : '',
					text : '全部'
				}, {
					value : '1',
					text : '是'
				}, {
					value : '2',
					text : '否'
				} ],
				onChange : function(value) {
					if (value == '') {
						$("#grid").datagrid('removeFilterRule', 'enable');
					} else {
						$("#grid").datagrid('addFilterRule', {
							field : 'enable',
							op : 'EQ',
							value : value
						});
					}
					$("#grid").datagrid('doFilter');
				}
			}
		} ]);
		$("#btn-delete").click(function() {
			multiDeleteDataGrid($grid, "${ctx}/basic/meetingRoom/multiDelete");
		});
		$("#excelExport").click(function() {
			var url = "${ctx}/basic/meetingRoom/excelExport?" + $.param($("#grid").datagrid('options').queryParams);
			if ($("#grid").datagrid("options").filterRules) {
				url += "&filterRules=" + JSON.stringify($("#grid").datagrid("options").filterRules);
			}
			window.parent.location.href = url;
		});
	});

	function fun_meeting_room_add() {
		$("#dlg").dialog("open").dialog("setTitle", "新增会议室");
		$("#fm").form("clear");
		$("#radio1").click();
	}

	function fun_meeting_room_edit() {
		var row = $("#grid").datagrid("getSelected");
		if (row == null) {
			showAlert("您未选择任何记录!");
		} else {
			$("#dlg").dialog("open").dialog("setTitle", "编辑会议室--[" + row.mrName + "]");
			$("#fm").form("clear").form("load", row);
		}
	}

	function fun_meeting_room_save() {
		var i = 0;
		if ($("#mrName").val() == null) {
			$.messager.show({
				msg : "您未输入会议室名称！",
				icon : "warning",
				position : "bottomRight"
			});
			i = 1;
		}
		if ($("#mrSize").val() == null) {
			$.messager.show({
				msg : "您未输入会议室容量！",
				icon : "warning",
				position : "bottomRight"
			});
			i = 1;
		}
		if ($("#mrAddress").val() == null) {
			$.messager.show({
				msg : "您未输入会议室地址！",
				icon : "warning",
				position : "bottomRight"
			});
			i = 1;
		}
		if (i == 0) {
			$("#fm").form("submit", {
				url : "${ctx}/basic/meetingRoom/update",
				success : function(data) {
					if (data.success) {
						$("#dlg").dialog("close");
						$("#grid").datagrid("load");
					}
					showInfo(data.msg);
				}
			});
		}
	}

	//查询条件
	function fun_search_meeting_room() {
		$("#grid").datagrid('load', {
			search_LIKE_mrName : $("#search_LIKE_mrName").val(),
			search_GTE_mrSize : $("#search_GTE_mrSize").val()
		});
	}
	//浏览该会议室的会议信息
	function fun_showInfo() {
		var row = $("#grid").datagrid("getSelected");
		if (row == null) {
			showAlert("未获取到行数");
		} else {
			$("#dlg1").dialog("open").dialog("setTitle", "查看--[" + row.mrName + "]会议安排");
			grid1 = $("#tb2").datagrid($.extend(datagridOption, {
				title : "",
				fitColumns : true,
				toolbar : "#",
				url : "${ctx}/basic/mrUseRecode/showInfo/" + row.id,
				columns : [ [ {
					field : 'id',
					checkbox : true
				}, {
					field : 'meetingSubject',
					title : '会议主题',
					disabled : 'disabled',
					width : 40,
					sortable : true
				}, {
					field : 'startTime',
					title : '会议起始时间',
					disabled : 'disabled',
					width : 60,
					sortable : true
				}, {
					field : 'endTime',
					title : '会议结束时间',
					disabled : 'disabled',
					width : 60,
					sortable : true
				} ] ]
			}));
			$("#tb2").datagrid('enableFilter', [ {
				field : 'startTime',
				type : 'datebox',
				javaType : 'D',
				op : [ 'EQ', 'NEQ', 'GT', 'LT', 'GTE', 'LTE', 'ISNULL', 'NOTNULL' ]
			}, {
				field : 'endTime',
				type : 'datebox',
				javaType : 'D',
				op : [ 'EQ', 'NEQ', 'GT', 'LT', 'GTE', 'LTE', 'ISNULL', 'NOTNULL' ]
			} ]);
		}
	}
</script>
</head>
<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
		<div id="tt" class="easyui-toolbar">
			<!-- 查询条件 -->
			<!-- 功能按钮 -->
			<shiro:hasPermission name="meetingRoom:update">
				<a id="btn-add" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain: true" onclick="fun_meeting_room_add()">新增会议室</a>
				<a id="btn-edit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-hamburg-pencil',plain: true"
					onclick="fun_meeting_room_edit()">修改</a>
			</shiro:hasPermission>
			<shiro:hasPermission name="meetingRoom:delete">
				<a id="btn-delete" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-hamburg-busy',plain: true">删除</a>
			</shiro:hasPermission>
			<shiro:hasPermission name="mrUseRecode:list">
				<a id="search" href="#" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-hamburg-zoom'" onclick="fun_showInfo()">查看会议信息</a>
			</shiro:hasPermission>
			<shiro:hasPermission name="meetingRoom:export">
				<a id="excelExport" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-standard-page-excel'">Excel导出</a>
			</shiro:hasPermission>

		</div>
		<shiro:hasPermission name="meetingRoom:update">
			<div id="dlg" class="easyui-dialog" style="width: 600px; height: 300px; padding: 10px 20px" closed="true"
				data-options="iconCls:'icon-save',resizable:true,modal:true, buttons:[
                    { text: '保存', iconCls: 'icon-ok', handler: function () { fun_meeting_room_save(); } },
                    { text: '取消', iconCls:'icon-cancel', handler: function () { $('#dlg').dialog('close'); } }
                ],closed:true">
				<form id="fm" method="post">
					<input id="id" type="hidden" name="id" />
					<table id="tbl">
						<tr>
							<td><label>会议室名称:</label></td>
							<td><input id="mrName" name="mrName" class="easyui-validatebox" data-options="required:true" /></td>
							<td><label>会议室地址:</label></td>
							<td><input id="mrAddress" name="mrAddress" class="easyui-validatebox" data-options="required:true" /></td>
						</tr>
						<tr>
							<td><label>会议时容量:</label></td>
							<td><input id="mrSize" name="mrSize" class="easyui-validatebox" data-options="required:true" /></td>
							<td><label>启用:</label></td>
							<td><input id="radio1" name="enable" type="radio" value="1" /><label for="radio1">是</label> <input id="radio2" name="enable"
								type="radio" value="2" /><label for="radio2">否</label></td>
						</tr>
						<tr>
							<td><label>备注:</label></td>
							<td colspan="3"><textarea id="remark" name="remark" rows="6px" cols="58px"></textarea></td>
						</tr>

					</table>
			</div>
		</shiro:hasPermission>
		<shiro:hasPermission name="mrUseRecode:list">
			<div id="dlg1" class="easyui-dialog" style="width: 600px; height: 400px; padding: 10px 20px" closed="true"
				data-options="iconCls:'icon-save',resizable:true,modal:true, buttons:[
                    { text: '取消', iconCls:'icon-cancel', handler: function () { $('#dlg1').dialog('close'); } }
                ],closed:true">
				<form id="showInfofm" method="post">
					<input id="id" type="hidden" name="id" />
					<table id="tb2">
					</table>
			</div>
		</shiro:hasPermission>
	</div>
</body>
</html>
